#define _CRT_SECURE_NO_WARNINGS	

/**
 * Definition for a binary tree node.
 * struct TreeNode {
 *     int val;
 *     struct TreeNode *left;
 *     struct TreeNode *right;
 * };
 */
 /**
  * Note: The returned array must be malloced, assume caller calls free().
  */
typedef struct TreeNode TreeNode;
int Count_Tree_Node(TreeNode* root)
{
    if (root == NULL)
        return 0;
    return 1 + Count_Tree_Node(root->left) + Count_Tree_Node(root->right);
}

void Mid_Order(TreeNode* root, int* arr, int* pi)
{
    if (root == NULL)
        return;
    Mid_Order(root->left, arr, pi);
    arr[(*pi)++] = root->val;
    Mid_Order(root->right, arr, pi);
}

int* inorderTraversal(struct TreeNode* root, int* returnSize)
{
    *returnSize = Count_Tree_Node(root);
    int* arr = (int*)malloc((*returnSize) * sizeof(int));
    int i = 0;
    Mid_Order(root, arr, &i);
    return arr;
}